package net.fkrahe.graph;

/**
 * Class WArcNode (Weightted ArcNode)
 * 
 * @author Yedidyah Langsan | Moshe Augenstein | Aaron M. Tenenbaum
 */
public class WArcNode extends ArcNode {

    private int weight;

    public WArcNode() {
        this(null, 0);
    }

    public WArcNode(int weight) {
        this(null, weight);
    }

    public WArcNode(GraphNode ptr, int weight) {
        super(ptr);
        this.weight = weight;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int w) {
        weight = w;
    }

    @Override
    public String toString() {
        if (ptr != null) {
            return "--(" + String.valueOf(weight) + ")--> " + ptr.getInfo().toString();
        } else {
            return String.valueOf(weight) + ";";
        }
    }
}
